<section class="post">
    <ol class="breadcrumb">
        <li><a href="#/">Blog</a></li>
        <li class="active">Administration</li>
    </ol>

    <div class="alert alert-danger" ng-show="message.is_error">{{message.message}}</div>
    <div class="alert alert-success" ng-show="message.is_success">{{message.message}}</div>

    <a href="#/admin/post/create" class="btn btn-success" style="margin-bottom: 15px;">Create a new post</a>

    <table class="table table-condensed table-hover">
        <thead>
            <tr>
                <th>Title</th>
                <th>Read</th>
                <th>Created</th>
                <th>Updated</th>
                <th>Action</th>
            </tr>
        </thead>
        <tbody> 
            <tr ng-repeat="post in posts">
                <td>{{post.title}}</td>
                <td>{{post.read}}</td>
                <td>{{post.created | date:'medium'}}</td>
                <td>{{post.updated | date:'medium'}}</td>
                <td>
                    <button ng-show="post.is_published" class="btn btn-warning btn-xs" ng-click="updatePublishState(post, false)"><span class="glyphicon glyphicon-eye-close"></span></button>
                    <button ng-show="!post.is_published" class="btn btn-success btn-xs" ng-click="updatePublishState(post, true)"><span class="glyphicon glyphicon-eye-open"></span></button>
                    
                    <a href="#/admin/post/edit/{{post._id}}" class="btn btn-warning btn-xs"><span class="glyphicon glyphicon-edit"></span></a>
                    <button class="btn btn-danger btn-xs" ng-click="deletePost(post._id)"><span class="glyphicon glyphicon-trash"></span></button>
                </td>
            </tr>
        </tbody>
    </table>

</section>
